import json
from tqdm import tqdm
from time import time
from milvus import MilvusOP
import pandas as pd

valid_set_pth = r'C:\Users\JHC258\Desktop\文本检索\evaluate\valid_set\t2q_error.json'
with open(valid_set_pth, 'r', encoding='utf-8') as f:
    text2query_ls = json.load(f)

config = {
    'tde': 0.7,
    'nde': 0.5,
    'tse': 0.3,
    'nse': 0.5,
    'added_value': 0.5
}
milvus_op = MilvusOP(db_name='state_vector_db', collection_name="hybrid")

total_time = 0
correct_num = 0
block_num = len(text2query_ls)
error_res = {}
type_set = {'.doc', '.docx', '.xls', '.xlsx', '.ofd', '.xml', '.jpg', '.pdf'}
bar = tqdm(text2query_ls.items(), desc='Milvus评估')
for key, value in bar:
    query = key
    label = value['label']
    label_type = value['type']
    start_time = time()
    res = milvus_op.hybrid_search([query], limit=100)
    end_time = time()
    total_time = total_time + (end_time - start_time)
    df = pd.DataFrame(res)
    print()
